/*
 * @Copyright: 2005-2018 www.2345.com. All rights reserved.
 */
package demo.redis.jedis;

//import redis.clients.jedis.BinaryJedis;
import redis.clients.jedis.Jedis;

import java.util.List;

public class JedisDemo {

    public static String host = "192.168.1.174";
    public static int port = 6380;
    public static String auth = "jredis123456";

    public static Jedis newJedis() {
        Jedis jedis = new Jedis(host, port);
        jedis.auth(auth);
        return jedis;
    }

//    public static BinaryJedis newBinaryJedis() {
//        BinaryJedis jedis = new BinaryJedis(host, port);
//        jedis.auth(auth);
//        return jedis;
//    }

    Jedis jedis;

//    BinaryJedis binaryJedis;

    public void initJedis(){
        System.out.println("----- initJedis -----");
        jedis = newJedis();
//        binaryJedis = newBinaryJedis();
    }


    public void testJedis() {
        String result = jedis.get("12345");
        System.out.println("str = " + result);

//        byte[] result2 = binaryJedis.get("125".getBytes());
//        System.out.println("byte[] = " + result2);

        List<String> result3 = jedis.mget("1", "2", "3", "4", "5");
        System.out.println("String[] = " + result3);

        Long l = jedis.bitpos("1", true);
        System.out.println("l = " + l);
    }

}
